﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T10Field
{
    class Program
    {
        static void Main(string[] args)
        {
            Accout a1 = new Accout();
            Console.WriteLine("{0}{1}",a1.type,Accout .total);

            a1.username = "张三";//修改实例字段

            Accout a2= new Accout();
            Console.WriteLine("{0}{1}", a2.type, Accout.total);

            a2.username = "李四";//修改实例字段

            //a2.type ="不能修改只读字段";//不能赋值

            Console.ReadKey();
        }
    }

    class Accout
    {
        public static int total;//静态字段-->属于类的所有对象
        public string username;//实例字段-->属于类的单个对象
        public const double PI = 3.1415;//常量字段
        public readonly string type;//只读字段-->可以在定义或构造函数中初始化

        public Accout()
        {
            total++;
            type = "账户类型";//在构造函数中初始化只读字段
        }

    }
}

